package kr.co.doriclassic.powerjava.chapter20;

public class StringBuilderEx {
	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		//문장의 끝에 삽입
		sb.append("Hello");
		System.out.println("sb.append(\"Hello\")"+sb);
		sb.append("Java");
		System.out.println("sb.append(\"Java\"):"+sb);
		
		char ch = sb.charAt(1);
		System.out.println("sb.charAt(1):"+ch);
		
		/*sb.delete(5, 8);//5부터 8-1까지
		System.out.println(sb);*/
		
		System.out.println("sb.indexOf(\"J\"):"+sb.indexOf("J"));
		//원하는 위치에 삽입
		sb.insert(5, " ");
		System.out.println("sb.insert(5, \" \");"+sb);
		
		
		System.out.println("sb.lastIndexOf(\"v\"):"+sb.lastIndexOf("v"));

		System.out.println("sb.length():"+sb.length());
		//바꾸기
		sb.replace(6, 10, "Android");
		System.out.println("sb.replace(6, 10, \"Android\"):"+sb);
		
		StringBuilder jumin = new StringBuilder("123456-1234567");
		//바꾸기
		jumin.replace(7, jumin.length(), "******");
		System.out.println("jumin.replace(7, jumin.length(), \"******\"):"+jumin);
		
		//역순
		//sb.reverse();
		//System.out.println(sb);
		//한문자 바꾸기
		sb.setCharAt(5, '*');
		System.out.println("sb.setCharAt(5, '*'):"+sb);
		//해당 자리수부터 출력
		String str = sb.substring(6);
		System.out.println("sb.substring(6):"+str);
		//해당자리수 + 범위 출력
		str = sb.substring(6, 9);
		System.out.println("sb.substring(6, 9):"+str);
	}
}
